package com.example.designpatterns.chain;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;

public class ChainLeader {
    List<Leader> list = new LinkedList<>();
    public void addLeader(Leader leader){
        if(list.size() == 0){
            list.add(0, leader);
        }{
            list.get(list.size()-1).setSuccessor(leader);
            list.add(list.size(), leader);
        }
    }
    public void deleteLeader(Leader leader){
        list.remove(leader);
    }
}
